package org.unisannio.sc;



import java.util.ArrayList;



import it.unipr.ce.dsg.s2p.sip.Address;
import android.R;
import android.app.ListActivity;

import android.os.Bundle;
import android.provider.ContactsContract.Data;
import android.view.View;
import android.widget.AdapterView;
import android.widget.TextView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;

public class AddressListActivity extends ListActivity {
	
	AddressArrayAdapter adapter;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);

		
		ArrayList<Address> indirizzi=ContactsActivity.contentRemote.retrieveAvailableAddress(Data.CONTENT_URI.toString());
		AddressArrayAdapter adapter=new AddressArrayAdapter(this,R.layout.activity_list_item,indirizzi);
		setListAdapter(adapter);
		ListView lv= getListView();
		lv.setTextFilterEnabled(true);
		
		lv.setOnItemClickListener(new OnItemClickListener() {

			public void onItemClick(AdapterView<?> arg0, View view, int arg2,
					long arg3) {
				((TextView) view).getText().toString();
				
			}
		});
	}
	
	
	
	@Override
	protected void onResume() {
		
		
		ArrayList<Address> indirizzi=ContactsActivity.contentRemote.retrieveAvailableAddress(Data.CONTENT_URI.toString());
		adapter=new AddressArrayAdapter(this,R.layout.activity_list_item,indirizzi);
		setListAdapter(adapter);
		
		super.onResume();
	}

	
	
}
